package base.day08;

import java.util.HashSet;
import java.util.Iterator;

/**
 * 描述：
 * 汉诺塔
 *
 * @author hl
 * @version 1.0
 * @date 2020/11/1 16:36
 */
public class Hanoi {
    //考虑只有两个盘子的情况，写出递归
    public static void func(int n, String from, String to, String help) {
        if (n == 1) {
            System.out.println("move 1 from " + from + " to " + to);
            return;
        }
        func(n - 1, from, help, to);
        System.out.println("move " + n + " from " + from + " to " + to);
        func(n - 1, help, to, from);
    }

    public static void main(String[] args) {
        hanoi(3);
        HashSet set = new HashSet();
        Iterator iterator = set.iterator();
        while(iterator.hasNext()){

        }
    }

    private static void hanoi(int n) {
        if (n > 0) {
            func(n, "左", "右", "中");
        }
    }
}
